package com.Ajava1704.tongbu;

import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 作者: LCG
 * 日期: 2020/2/10 10:40
 * 描述:
 */
public class Test0210tongbu {

    public static void main(String[] args) throws InterruptedException, ExecutionException {

        Thread t1=new Thread(new TestR2(),"A");
        t1.start();

        Thread t2=new Thread(new TestR2(),"B");
        t2.start();


        FutureTask<Integer> futureTask = new FutureTask<Integer>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                System.out.println("======业务代码======");
                return 1;
            }
        });
        Thread thread=new Thread(futureTask);

        thread.start();

        FutureTask<Integer> futureTask2 = new FutureTask<Integer>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                System.out.println("======业务代码======");
                return 2;
            }
        });
        Thread thread2=new Thread(futureTask2);

        thread2.start();


        Integer integer = futureTask.get();
        Integer integer1 = futureTask2.get();
        System.out.println("================="+(integer+integer1));






    }

}
